package skiree.host.abetsy.api.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ScheduledService {

    @Autowired
    private EventQueueServer eventQueueServer;

    @Scheduled(cron = "0/2 * * * * *")
    public void eventQueue() {
        Map<Integer, EventQueueModel> queueModelWaitingMap = eventQueueServer.getQueueModelWaitingMap();
        if (queueModelWaitingMap.isEmpty()) {
            return;
        }
        eventQueueServer.doEvent();
    }

    @Scheduled(cron = "0/1 * * * * *")
    public void ThreadPoolInfo() {
        ThreadPoolUtil.getInstance().computePoolInfo();
    }

}
